<?php
session_start();
$user = $_SESSION['user'];

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="ico/logo.ico" type="image/x-icon" />
    <title>协同办公-添加用户</title>
    <link rel="stylesheet" href="../static/css/bootstrap.css">
    <link rel="stylesheet" href="../static/js/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/font.css">
    <link rel="stylesheet" href="../static/css/main.css">
    <style>


    </style>
</head>
<body>
<div id="logo"><div id="logo-img"><img src="../static/imaegs/logo/logo2.png"></div>
<div id="logo-right">
    <h5 ><i class="layui-icon" style="font-size: 18px; color: orange">&#xe645;</i>&nbsp;最新公告：<span id="notice">暂无公告</span></h5>
</div>
</div>
<div id="tiao">
    <div id="left"><a href="index.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe68e;</i>&nbsp;首页</a>
        <a href="task.php"> <i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe6b2;</i>&nbsp;任务</a>
        <a href="notice/notice.php"> <i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe637;</i>&nbsp;公告栏</a>
        <a href="file.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe621;</i>&nbsp;文件管理</a>
        <a style="color: blue"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe613;</i>&nbsp;用户管理</a></div>
    <div id="right"><a style="color:grey" href="index.php">您好！&nbsp;</a><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe66f;</i><input id="user" name="user" readonly="readonly" value="<?php echo $user ?>"><a href="login.html">退出</a></div>
</div>

<div id="from_block">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">团队成员</li>
            <li>新生</li>

        </ul>
        <div class="layui-tab-content" style="height: 200px;">
            <div class="layui-tab-item layui-show">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <xblock>
                            <button class="layui-btn" onclick="member_add()"><i class="layui-icon">&#xe608;</i>添加</button><span class="x-right" style="line-height:40px"></xblock>
                        <table class="layui-table" lay-data="{width: 1000, height:500, url:'../php/user/select_user.php', page:true, id:'idTest'}" lay-filter="demo">
                            <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{field:'id', width:80, sort: true, fixed: true}">ID</th>
                                <th lay-data="{field:'user', width:150}">用户名</th>
                                <th lay-data="{field:'class', width:150}">团队名称</th>
                                <th lay-data="{field:'email', width:200}">邮箱</th>
                                <th lay-data="{field:'tel', width:200}">电话</th>
                                <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th>
                            </tr>
                            </thead>
                        </table>

                        <script id="barDemo" type="text/html">

                            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                        </script>
                    </div>

                </div>
            </div>
            <div class="layui-tab-item">


                <div class="layui-row layui-col-space15" >
                    <div class="layui-col-md12" >
                        <table class="layui-table" lay-data="{width: 1000, height:500, url:'../php/user/select_new_user.php', page:true, id:'idTestA'}" lay-filter="demoA">
                            <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{field:'id', width:80, sort: true, fixed: true}">ID</th>
                                <th lay-data="{field:'user', width:150}">姓名</th>
                                <th lay-data="{field:'major', width:150}">专业</th>
                                <th lay-data="{field:'email', width:200}">邮箱</th>
                                <th lay-data="{field:'tel', width:200}">电话</th>
                                <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemoA'}"></th>
                            </tr>
                            </thead>
                        </table>

                        <script id="barDemoA" type="text/html">
                            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detailA">查看</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delA">删除</a>
                        </script>
                    </div>
                </div>


            </div>
        </div>
    </div>


</div>

<img  id="hua1" src="../static/imaegs/122.png">
<div id="footer">
    <hr style="margin-top: 100px">
    <a id="fot-word">
        版权信息：xianghai保留所有权利，请尊重他人的劳动成果   ||    备案号：蜀ICP备18021117号
        ||           地址：四川省成都市高新区天一街83号软件大楼
    </a>
</div>
<script src="../static/js/jquery.min.js"></script>
<script src="../static/js/layui/layui.all.js"></script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择alert(count);
        table.on('checkbox(demo)', function(obj){
            console.log(obj);

        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
              $id=data.id;
                layer.confirm('真的删除行么', function(index) {
                    member_del($id);
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                $id=data.id;
                member_edit($id);
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择alert(count);
        table.on('checkbox(demoA)', function(obj){
            console.log(obj);

        });
        //监听工具条
        table.on('tool(demoA)', function(obj){
            var data = obj.data;
            if(obj.event === 'detailA'){
                window.location.href="show.php?id="+data.id;
            }
            else if(obj.event === 'delA'){
                $id=data.id;
                layer.confirm('真的删除行么', function(index) {
                    $.ajax({
                        type: 'post',
                        cache: false,
                        url: '../php/user/del_new_user.php',
                        data: {
                            "id":data.id,
                        },
                        dataType: 'json',
                        success: function (data) {
                            layer.msg(data.message);
                            obj.del();
                            layer.close(index);
                        },
                        error: function (data) {
                            layer.msg("删除失败");
                        }
                    });


                });
            }
        });


    });

    $user=$('#user').val();
    if($user===""){
        layer.msg("您还没有登陆哦！");
        window.location.href="login.html";

    }
else {
        function member_add() {
            layer.open({
                type: 2,
                title: '用户添加',
                shadeClose: true,
                shade: 0.8,
                area: ['380px', '50%'],
                content: 'member-add.html',
            });

        }

        /*用户-删除*/
        function member_del($id) {
            $.ajax({
                type: 'post',
                cache: 'false',
                url: '../php/user/delete_user.php',
                data: {
                    "id": $id,
                },
                dataType: 'json',
                success: function (dat) {

                },
                error: function (dat) {
                    layer.msg("获取数据异常");
                }

            });
            layer.msg('已删除!', {icon: 1, time: 1000});
        }


        // 用户-编辑
        function member_edit($id) {
            layer.open({
                type: 2,
                title: '用户添加',
                shadeClose: true,
                shade: 0.8,
                area: ['380px', '50%'],
                content: 'member-edit.html?id=' + $id,
            });
        }
    }
    $.ajax({
        type: 'post',
        cache: false,
        url: '../php/admin/select_notice.php',
        data: {
            "user":$user,
        },
        dataType: 'json',
        success: function (data) {
            $dat = data.data;
            $notice=$dat[0].content;
            var not=document.getElementById("notice");
            not.innerHTML=$notice;
        },
        error: function (data) {

        }
    });
</script>

</body>
</html>